/* GUI CONVERTED from rprsrp1a.p (converter v1.75) Mon Oct 23 21:05:01 2000 */
/* rprsrp1a.p - RESOURCE LOAD SUMMARY REPORT                            */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/* All rights reserved worldwide.  This is an unpublished work.        */
/*F0PN*/ /*K1D9*/
/*V8:ConvertMode=Report                                        */
/* REVISION: 1.0     LAST MODIFIED: 04/18/86    BY: pml                 */
/* REVISION: 2.0     LAST MODIFIED: 01/06/88    BY: pml *A125*          */
/* REVISION: 4.0     LAST MODIFIED: 02/24/88    BY: wug *A175*          */
/* REVISION: 4.0     LAST MODIFIED: 03/23/88    BY: rl  *A171*          */
/* REVISION: 4.0     LAST MODIFIED: 06/20/89    BY: emb *A748*          */
/* REVISION: 4.0     LAST MODIFIED: 02/22/90    BY: wug *B583*          */
/* REVISION: 5.0     LAST MODIFIED: 04/04/90    BY: ram *B640*          */
/* REVISION: 6.0     LAST MODIFIED: 04/10/90    BY: ram *D018*          */
/* REVISION: 6.0     LAST MODIFIED: 06/01/90    BY: ram *D028*          */
/* REVISION: 5.0     LAST MODIFIED: 06/08/90    BY: ram *B705*          */
/* REVISION: 5.0     LAST MODIFIED: 09/27/90    BY: ram *B793*          */
/* REVISION: 7.0     LAST MODIFIED: 10/11/91    BY: emb *F024*          */
/* REVISION: 7.3     LAST MODIFIED: 10/23/92    BY: ram *G231*          */
/* REVISION: 7.3     LAST MODIFIED: 10/17/95    BY: qzl *G0ZB*          */
/* REVISION: 8.6     LAST MODIFIED: 12/11/97    BY: bvm *K1D9*          */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/11/00   BY: *N0K5* Arul Victoria    */
/* REVISION: 9.1      LAST MODIFIED: 10/23/00   BY: *N0T0* Katie Hilbert    */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

     {mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rprsrp1a_p_1 "Per Column"
/* MaxLen: Comment: */

/*N0T0***BEGIN DELETE
 * &SCOPED-DEFINE rprsrp1a_p_2 "Day/Week/Month"
 * /* MaxLen: Comment: */
 *N0T0***END DELETE*/

&SCOPED-DEFINE rprsrp1a_p_6 "Over Cap %"
/* MaxLen: Comment: */

&SCOPED-DEFINE rprsrp1a_p_7 "Output"
/* MaxLen: Comment: */

&SCOPED-DEFINE rprsrp1a_p_10 "Under Cap %"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 * &SCOPED-DEFINE rprsrp1a_p_3 "Past    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp1a_p_4 "Cumulative    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp1a_p_5 "Over/Under    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp1a_p_8 "Capacity      "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp1a_p_9 "Total Load    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp1a_p_11 "Workdays      "
 * /* MaxLen: Comment: */
 *
 *N0K5* ------------------- END   DELETE ----------------------- */

/*K1D9*/ {wbrp02.i}

     define shared variable start like rq_start.
     define variable rscde like rq_rsc no-undo.
     define variable interval as integer extent 13 no-undo.
     define variable sdate like ro_start extent 13 no-undo.
     define variable load as decimal extent 13 format "->>>,>>9" no-undo.
     define variable cap as decimal extent 13 format "->>>,>>9" no-undo.
     define variable ovund as decimal extent 13 format "->>>,>>9" no-undo.
     define variable cum as decimal extent 13 format "->>>,>>9" no-undo.
     define variable workdays as integer extent 13 format ">>>>,>>9" no-undo.
     define variable det_load as decimal extent 13 format "->>>,>>9" no-undo.
     define variable i as integer no-undo.
     define variable j as integer no-undo.
     define variable qty like rq_qty no-undo.
     define variable nonwdays as decimal no-undo.
     define variable elapsedays as integer no-undo.
     define variable wdays as integer no-undo.
     define variable overlap as integer no-undo.
     define variable wointerval as integer no-undo.
     define variable ltoffperiod as integer no-undo.
     define variable lead as integer no-undo.
     define variable num_intervals as integer initial 12 no-undo.
/*N0T0*     define shared variable dwm as character format "!"  */
/*N0T0*        label {&rprsrp1a_p_2}.                           */
/*N0T0*/define shared variable dwm as character.
     define shared variable idays as integer format ">>>>>9"
        label {&rprsrp1a_p_1}.
     define variable monthend as integer no-undo.
     define shared variable rsc like rs_rsc.
     define shared variable rsc1 like rs_rsc.
     define shared variable upct like wc_bdn_pct label {&rprsrp1a_p_10}.
     define shared variable opct like wc_bdn_pct label {&rprsrp1a_p_6}.
     define variable printflg as character no-undo.
     define shared variable dev as character format "x(8)" label {&rprsrp1a_p_7}.

     define shared variable site like si_site.
     define shared variable site1 like si_site.
/*N0T0***********BEGIN DELETE OF UNUSED LOCAL VARIABLES
 * define variable holiday as integer.
 * define variable wostart as integer.
 * define variable offset like rq_lt_off.
 * define variable ltoff like rq_lt_off.
 *N0T0***********END DELETE*/

     for each rs_mstr no-lock where (rs_rsc >= rsc and rs_rsc <= rsc1)
     and (rs_site >= site and rs_site <= site1):

        if opct = 0 and upct = 0 then
           printflg = "yes".
        else
           printflg = "no".

        /* COMPUTE START DATES */
        sdate[1] = today.
        {mfcsdate.i}

        do i = 1 to num_intervals + 1:
           sdate[i] = max(sdate[i],today).
           if i > 1 then interval[i - 1] = max(sdate[i] - sdate[i - 1],0).
        end.

        /* INITIALIZE VARIABLES */
        assign
           workdays = 0
           cap = 0
           load = 0
           ovund = 0
           cum = 0.

        /* CALCULATE WORKING DAYS IN EACH INTERVAL */
        {mfcwdays.i rs_site}
        do i = 1 to num_intervals:
           workdays[i] = max(workdays[i],0).
        end.

        /* CALCULATE CAPACITY IN EACH INTERVAL */
        rscde = rs_rsc.
/*G231      {mfccap.i} */
/*G231*/    {mfccap.i rs_site}

        {mfcsdate.i}
        {mfcwdays.i rs_site}
        workdays[1] = max(workdays[1],0).
        sdate[1] = low_date.

        /* CALCULATE LOAD IN EACH PERIOD  */
        find shop_cal no-lock where shop_site = rs_site
        and shop_wkctr = "" and shop_mch = "" no-error.

        if not available shop_cal then
        find shop_cal no-lock where shop_site = ""
        and shop_wkctr = "" and shop_mch = "" no-error.

        if available shop_cal then

           repeat with frame c no-labels:

           rscde = rs_rsc.
           for each rq_mstr no-lock where rq_rsc = rscde
           and rq_site = rs_site
           by rq_part:

          for each wo_mstr no-lock where wo_part = rq_part
          and wo_site = rq_site
          and (wo_due >= rq_start or rq_start = ?)
          and (wo_due <= rq_end or rq_end = ?)
          and (wo_qty_ord - wo_qty_comp - wo_qty_rjct > 0)
          and wo_status <> "C"
/*G0ZB*/          and wo_type <> "C"
          by wo_nbr:

             /* CALCULATE LOAD INTERVALS FOR A GIVEN WORK ORDER  */
             {mfcload.i}

          end.
           end.
           leave.
        end.

        /* CALCULATE LOAD OVER/UNDER AND CUMULATIVE */
        do i = 1 to num_intervals:
           ovund[i] = cap[i] - load[i].
           if printflg = "no" and ovund[i] <> 0 then do:
          if (opct <> 0 and ovund[i] <= -1 * cap[i] * opct / 100)
          or (upct <> 0 and ovund[i] >= cap[i] * upct / 100) then
             printflg = "yes".
           end.
           ovund[i] = integer(ovund[i]).
           cum[i] = ovund[i].
           if i > 1 then cum[i] = cum[i] + cum[i - 1].
        end.

        if printflg = "yes" then do:
           if page-size - line-counter < 12 then page.
/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 *         /* Removed as frame c is no-labels frame */
 *         /* SET EXTERNAL LABELS */
 *         setFrameLabels(frame c:handle).
 *N0K5* ------------------- END   DELETE ----------------------- */

           display rs_rsc rs_desc no-label rs_um space(6) rs_site
           with
/*N0K5*/   frame e
           width 132 side-labels STREAM-IO /*GUI*/ .

/*N0K5* ------------------- BEGIN ADD ----------------------- */
           /* SET EXTERNAL LABELS */
           setFrameLabels(frame e:handle).
/*N0K5* ------------------- END   ADD ----------------------- */

/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 *            display space(15) {&rprsrp1a_p_3} sdate[2 for 11] skip space(15)
 *           sdate[2] - 1  sdate[3] - 1  sdate[4] - 1  sdate[5] - 1
 *           sdate[6] - 1  sdate[7] - 1  sdate[8] - 1  sdate[9] - 1
 *           sdate[10] - 1 sdate[11] - 1 sdate[12] - 1 sdate[13] - 1
 *           skip space(15)
 *           "-------- -------- -------- -------- -------- --------"
 *           "-------- -------- -------- -------- -------- --------"
 *           {&rprsrp1a_p_11} workdays[1 for 12] skip
 *           {&rprsrp1a_p_8} cap[1 for 12] skip
 *            with frame b no-labels width 132.
 *
 *            display
 *           {&rprsrp1a_p_9} load[1 for 12] skip
 *           {&rprsrp1a_p_5} ovund[1 for 12] skip
 *           {&rprsrp1a_p_4} cum[1 for 12] skip
 *            with frame d no-labels width 132.
 *N0K5* ------------------- END   DELETE ----------------------- */

/*N0K5* ------------------- BEGIN ADD ----------------------- */
           display space(15)
          getTermLabel("PAST",8)
          sdate[2 for 11] skip space(15)
          sdate[2] - 1  sdate[3] - 1  sdate[4] - 1  sdate[5] - 1
          sdate[6] - 1  sdate[7] - 1  sdate[8] - 1  sdate[9] - 1
          sdate[10] - 1 sdate[11] - 1 sdate[12] - 1 sdate[13] - 1
          skip space(15)
          "-------- -------- -------- -------- -------- --------"
          "-------- -------- -------- -------- -------- --------"
         getTermLabel("WORKDAYS",14) format "x(14)" workdays[1 for 12] skip
         getTermLabel("CAPACITY",14) format "x(14)" cap[1 for 12] skip
           with frame b no-labels width 132 STREAM-IO /*GUI*/ .

           display
         getTermLabel("TOTAL_LOAD",14) format "x(14)" load[1 for 12] skip
         getTermLabel("OVER/UNDER",14) format "x(14)" ovund[1 for 12] skip
         getTermLabel("CUMULATIVE",14) format "x(14)" cum[1 for 12] skip
           with frame d no-labels width 132 STREAM-IO /*GUI*/ .
/*N0K5* ------------------- END   ADD ----------------------- */
        end.

        
/*GUI*/ {mfguirex.i } /*Replace mfrpexit*/

     end.
/*K1D9*/ {wbrp04.i}
